package com.gemme.gemme.view;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.media.Image;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;

public class Topview extends RelativeLayout {
    private Context context;

    public Topview(Context context) {
        this(context,null);
    }

    public Topview(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public Topview(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    ImageView arrow_left;
    TextView contentText;
    View rl_content;
    public TextView rightText;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.top_view,this);
        rl_content = findViewById(R.id.rl_content);
        arrow_left = findViewById(R.id.arrow_left);

        contentText = findViewById(R.id.contentText);

        rightText = findViewById(R.id.rightText);


        arrow_left.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if(context instanceof Activity){
                    Activity act= (Activity)context;
                    act.finish();
                }
            }
        });
    }

    public Topview whiteTextColor(){
        rl_content.setBackgroundColor(0);
        contentText.setTextColor(Color.parseColor("#FFFFFFFF"));
        arrow_left.setBackgroundResource(R.drawable.arrow_left_whte);
        return this;
    }


    public Topview setContentText(String str){
        rl_content.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
        contentText.setText(str + "");
        return this;
    }


    public Topview setContentViewVisible(boolean isVisible){
        if(isVisible){
            contentText.setVisibility(VISIBLE);
        }else{
            contentText.setVisibility(GONE);
        }
        return this;
    }

    public void setRightText(String rightTextstr) {
        rightText.setText(rightTextstr);
        rightText.setVisibility(VISIBLE);
    }

    public TextView getRightText() {
        return rightText;
    }



    public TextView getContentText() {
        return contentText;
    }
}
